package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysApply;
import com.ruoyi.project.system.service.ISysApplyService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 入驻申请Controller
 * 
 * @author jjp
 * @date 2020-04-24
 */
@RestController
@RequestMapping("/system/apply")
public class SysApplyController extends BaseController
{
    @Autowired
    private ISysApplyService sysApplyService;

    /**
     * 查询入驻申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:apply:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysApply sysApply)
    {
        startPage();
        List<SysApply> list = sysApplyService.queryApplyList(sysApply);
        return getDataTable(list);
    }

    /**
     * 获取入驻申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:apply:query')")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") Long applyId)
    {
        return AjaxResult.success(sysApplyService.selectSysApplyById(applyId));
    }

    /**
     * 新增入驻申请
     */
    @PreAuthorize("@ss.hasPermi('system:apply:add')")
    @Log(title = "入驻申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysApply sysApply)
    {
        return toAjax(sysApplyService.insertSysApply(sysApply));
    }

    /**
     * 修改入驻申请
     */
    @PreAuthorize("@ss.hasPermi('system:apply:edit')")
    @Log(title = "入驻申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysApply sysApply)
    {
        return toAjax(sysApplyService.updateSysApply(sysApply));
    }

    /**
     * 删除入驻申请
     */
    @PreAuthorize("@ss.hasPermi('system:apply:remove')")
    @Log(title = "入驻申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable Long[] applyIds)
    {
        return toAjax(sysApplyService.deleteSysApplyByIds(applyIds));
    }
}
